<template>
	<view class="container">
		<view class="two_code">
			<!-- #ifndef APP-PLUS -->
			<image class="img" :src="twoCode" mode="aspectFill"></image>
			<!-- #endif -->
			<!-- #ifdef APP-PLUS -->
			<image class="img" :src="twoCode" mode="aspectFill" @longpress="alertPop()"></image>
			<!-- #endif -->
		</view>
	</view>
</template>

<script>
	import config from '@/common/js/config.js';
	export default {
		data() {
			return {
				pintuan_trader_level: '',
				pintuan_trader_level_name: '',
				code: 'GF12546',
				//代理商member_id
				member_id: '124',
				//请求类型
				req_one: 'first',
				req_two: 'two',
				twoCode: ''
			}
		},
		onLoad(option) {
			let memberInfo = uni.getStorageSync('userInfo');
			this.member_id = memberInfo.member_id;
			this.gettwoCode();
		},
		onShow() {
			this.gettwoCode();
		},
		methods: {
			alertPop() {
				let that = this;
				uni.showActionSheet({
				    itemList: ['保存海报'],
				    success: function (res) {					
						uni.downloadFile({ //获得二维码的临时地址
							url: that.twoCode,
							success: (res) => {
								if (res.statusCode == 200) {
									uni.saveImageToPhotosAlbum({
										filePath: res.tempFilePath, //传入临时地址
										success() {
											that.$util.showToast({
												title: '保存成功!!!'
											})
										},
										fail() {
											that.$util.showToast({
												title: '登录失败'
											});
										}
									})
								}
							}
						})
				    },
				    fail: function (res) {
				        console.log(res.errMsg);
				    }
				});
			},
			closePopup() {
				this.$refs.savePopup.close();
			},
			go() {
				uni.previewImage({
					urls: this.twoCode.path,
					longPressActions: {
						itemList: ['发送给朋友', '保存图片', '收藏'],
						success: function(res) {
							console.log('选中了第' + (res.tapIndex + 1) + '个按钮');
						},
						fail: function(res) {
							console.log(res.errMsg);
						}
					}
				});
			},
			gettwoCode() {
				this.$api.sendRequest({
					url: '/platformpintuan/api/Pintuantrader/getAgentPoster',
					data: {
						path: config.h5Domain + '/pages/index/index/index?member_id=' + this.member_id + '&type=bind_agent',
					},
					success: res => {
						if (res.code == 0) {
							console.log(res.data);
							this.twoCode = res.data.poster_path;
						} else {
							this.$util.showToast({
								title: res.message
							});
						}
					}
				});
			}
		}
	}
</script>

<style lang="scss" scoped>
	.gray-text {
		color: #91949A;
	}

	.container {
		width: 100vw;
		background-color: #e73640;

		/* #ifdef H5  */
		background-color: #e73640;
		height: calc(100vh - 90rpx) !important;
		/* #endif	  */


		/* #ifdef APP-PLUS  */
		height: 100vh !important;
		/* #endif	  */


		display: flex;
		justify-content: center;
		align-items: flex-end;
		//padding-bottom: 5%;

		.two_code {
			width: 100vw;
			height: 100vh;

			.img {
				width: 100%;
				height: 100%;
			}
		}
		
		.share-popup,
		.uni-popup__wrapper-box {
			.share-title {
				line-height: 60rpx;
				font-size: $ns-font-size-lg;
				padding: 15rpx 0;
				text-align: center;
			}
		
			.share-content {
				display: flex;
				display: -webkit-flex;
				-webkit-flex-wrap: wrap;
				-moz-flex-wrap: wrap;
				-ms-flex-wrap: wrap;
				-o-flex-wrap: wrap;
				flex-wrap: wrap;
				padding: 15rpx;
		
				.share-box {
					flex: 1;
					text-align: center;
		
					.share-btn {
						margin: 0;
						padding: 0;
						border: none;
						line-height: 1;
						height: auto;
						text {
							margin-top: 20rpx;
							font-size: 24rpx;
							display: block;
							color: $ns-text-color-black;
						}
					}
		
					.iconfont {
						font-size: 80rpx;
						line-height: initial;
					}
					.iconpengyouquan,
					.iconiconfenxianggeihaoyou {
						color: #07c160;
					}
				}
			}
		
			.sub {
				display: flex;
				justify-content: space-around;
				.share-footer {
					height: 90rpx;
					line-height: 90rpx;
					border-top: 2rpx #f5f5f5 solid;
					text-align: center;
					color: #666;
				}
				
			}
			.share-footer {
				height: 90rpx;
				line-height: 90rpx;
				border-top: 2rpx #f5f5f5 solid;
				text-align: center;
				color: #666;
			}
		}

		// .two_code {
		// 	box-sizing: border-box;
		// 	width: 704rpx;
		// 	height: 790rpx;
		// 	border-radius: 10rpx;
		// 	background-color: #FFFFFF;
		// 	margin-bottom: 4%;
		// 	display: flex;
		// 	flex-direction: column;
		// 	justify-content: center;
		// 	align-items: center;

		// 	.two_code_title {


		// 		font-size: 55rpx;
		// 		color: #F65034;

		// 		line-height: 55rpx;
		// 		font-weight: 500;
		// 	}

		// 	.image-box {
		// 		width: 355rpx;
		// 		height: 356rpx;
		// 		margin: 71rpx 0 38rpx 0;
		// 		// border: 1rpx solid red;

		// 		image {
		// 			width: 100%;
		// 			height: 100%;
		// 		}
		// 	}
		// }

	}
</style>
